<#assign tit>客诉录入</#assign>
<@page.html title=tit>
<style>table.list th, table.list td {padding:2px;}</style>
<script type="text/javascript" src="${_appPath!}/js/upload.js"></script>
<script type="text/javascript">
  function getminfo(c, t) {
    if(c!="") {
      getJson("getMember?"+(t==1?"memberCode":"earnestId")+"="+c, function(data){
        if(data.ret) {
          var mb = data.data;
          setc(mb);
        } else {
          window.alert(data.msg);
          setc(null);
        }
      });
    } else {
      setc(null);
    }
  }
  function setc(mb) {
    var fm = getEl("fm_input");
    var div = getEl("div_conls");
    if(mb) {
      fm.earnestId.value = mb.earnestId;
      fm.memberCode.value = mb.memberCode;
      fm.cardCode.value = mb.cardCode;
      fm.memberName.value = mb.memberName;
      fm.idNumber.value = mb.idTypeName+" "+mb.idNumber;
      fm.mobile.value = mb.mobile;
      fm.memberShop.value = mb.shopName;
      var arr = [];
      arr.push('<table class="list">'
          + '<tr>'
          + '  <th></th>'
          + '  <th>门店</th>'
          + '  <th>合同号</th>'
          + '  <th>合同类型</th>'
          + '  <th>销售类型</th>'
          + '  <th>课程/卡种</th>'
          + '  <th>金额</th>'
          + '  <th>开始日期</th>'
          + '  <th>结束日期</th>'
          + '  <th>剩余次数</th>'
          + '</tr>');
      if(mb.contract && mb.contract.length>0) {
        for(var i=0; i<mb.contract.length; i++) {
          arr.push('<tr'+(i%2?' class="line2"':' class="line1"')+'><td class="no"><input type="checkbox" name="cbcon" value="'+mb.contract[i]+'"/></td>');
          var ss = mb.contract[i].split(",");
          for(var j=0; j<ss.length; j++)
            arr.push('<td>'+ss[j]+'</td>');
          arr.push('</tr>');
        }
      } else {
        arr.push('<tr><td>无相关合同</td></tr>');
      }
      arr.push('</table>');
      div.innerHTML = arr.join("");
    } else {
      fm.cardCode.value = "";
      fm.memberName.value = "";
      fm.idNumber.value = "";
      fm.mobile.value = "";
      fm.memberShop.value = "";
      div.innerHTML = "";
    }
  }

  function save(fm) {
    var arr = [];
    var cbs = document.getElementsByName("cbcon");
    if(cbs) {
      for(var i=0; i<cbs.length; i++)
        if(cbs[i].checked) arr.push(cbs[i].value);
    }
    fm.contractNote.value = arr.join("|");
    return post(fm);
  }

  function uploadSucc(f) {
    var td = getEl("td_img");
    if(td) {
      var sp = document.createElement("SPAN");
      td.appendChild(sp);
      sp.innerHTML = '<img src="${_picPath!}'+ f.furl+'" style="max-width:220px;"/>';
    }
    var ipt = getEl("ipt_pics");
    ipt.value = ipt.value + (ipt.value!=""?",":"") + f.furl;
  }
</script>
<div style="width:700px;">
  <div class="kbox">
    <form id="fm_input" method="post" action="_add" onsubmit="return save(this);">
      <input type="hidden" name="picUrls" id="ipt_pics" value="">
      <input type="hidden" name="contractNote" value="">
      <table class="input w4" style="margin-left:25px;">
        <tr>
          <th width="85">客诉门店</th>
          <td width="160"><select name="shopCode"><#if shopName??><#list shopName as t><option value="${t.id}"<#if complaint.shopCode?? && complaint.shopCode=t.id> selected</#if>>${t.id} - ${t.name!}</option></#list></#if></select></td>
          <th width="85"></th>
          <td width="160"></td>
        </tr>
        <tr>
          <th>会员编号</th>
          <td><input type="text" name="memberCode" value="" onchange="getminfo(this.value,1);" maxlength="20"></td>
          <th>或定金号</th>
          <td><input type="text" name="earnestId" value="" onchange="getminfo(this.value,2);" maxlength="20"></td>
        </tr>
      </table>
      <div style="border:3px solid #ffefce; padding:5px 0 10px 12px;">
        <table class="input w4" style="margin-left:10px;">
          <tr>
            <th width="85">会员姓名</th>
            <td width="160"><input type="text" name="memberName" value="" readonly class="disable"></td>
            <th width="85">会员卡号</th>
            <td width="160"><input type="text" name="cardCode" value="" readonly class="disable"></td>
          </tr>
          <tr>
            <th>证件号</th>
            <td colspan="3"><input type="text" name="idNumber" value="" readonly class="w2 disable"></td>
          </tr>
          <tr>
            <th>手机号码</th>
            <td><input type="text" name="mobile" value="" readonly class="disable"></td>
            <th>所属门店</th>
            <td><input type="text" name="memberShop" value="" readonly class="disable"></td>
          </tr>
        </table>
        <div id="div_conls" style="width:610px;"></div>
      </div>
      <table class="input w4" style="margin-left:25px;">
        <tr>
          <th width="85">客诉分类</th>
          <td width="160"><select name="type" req="客诉分类"><option value=""></option><#if complaintType??><#list complaintType as t><option value="${t.id}">${t.name}</option></#list></#if></select></td>
          <th width="85">紧急程度</th>
          <td width="160"><select name="priority" req="紧急程度"><option value=""></option><#if complaintPriority??><#list complaintPriority as t><option value="${t.id}">${t.name}</option></#list></#if></select></td>
        </tr>
        <tr>
          <th>客诉标题</th>
          <td colspan="3"><input type="text" name="title" value="${complaint.title!}" req="标题" size="40" maxlength="50" class="w2"></td>
        </tr>
        <tr>
          <th>诉求记录</th>
          <td colspan="3"><textarea name="content" cols="40" rows="6" req="内容" style="height:100px;">${complaint.content!}</textarea></td>
        </tr>
        <tr>
          <th>处理分类</th>
          <td><select name="procType" req="处理分类"><option value=""></option><#if complaintProcType??><#list complaintProcType as t><option value="${t.id}">${t.name}</option></#list></#if></select></td>
          <th>投诉原因</th>
          <td><select name="complainReason" req="投诉原因"><option value=""></option><#if complainReason??><#list complainReason as t><option value="${t.id}">${t.name}</option></#list></#if></select></td>
        </tr>
        <tr>
          <th>风险金扣除</th>
          <td colspan="3"><input type="text" name="riskMoney" value="${complaint.riskMoney!}" size="40" maxlength="200" class="w2"></td>
        </tr>
      </table>
    </form>
    <table class="input" style="margin-left:25px;">
      <tr>
        <th width="85">上传图片</th>
        <td><form id="fm_upload" action="_upload" method="post" enctype="multipart/form-data" target="ifm_upload">
          <input type="file" name="file" id="ip_file" size="22" /> <input type="button" class="opwin" value="上传" onclick="chkupload();"></form>
          <iframe name="ifm_upload" onload="uploadOk(this);" style="width:0px; height:0px; display:none;"></iframe>
          <div id="div_wait" style="position:absolute; display:none; border:1px solid #999; top:-5px; left:50px; background-color:#fffff0; padding:12px 50px;"><span class="loading">正在上传，请稍等。。。</span></div></td>
      </tr>
      <tr>
        <th></th>
        <td id="td_img"></td>
      </tr>
    </table>
  </div>
  <div class="button"><input type="button" value="提 交" onclick="save(getEl('fm_input'));"></div>
</div>
</@page.html>